package api.h5tbx;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import java.lang.ref.SoftReference;

/**
 * Created by wilbur on 2017/12/15.
 */

public abstract class Router_H5tbx {
    public static final int JUMP_INNER_APP = 0;
    public static final int JUMP_FROM_NOTIFCATION = 1;
    private static SoftReference<Router_H5tbx> sf;

    public static String clazz = "com.dt.h5toolbox.api.H5tbx_API";

    public abstract void jump2H5Box(Context cxt, int jumType);
    public abstract void onEndView();
    public abstract void onStartView();
    public abstract void onDestory();
    public abstract void load(Activity act);
    public abstract boolean isGPVersion();
    public abstract void setSettingOnClickLinster(View.OnClickListener linster);
    public abstract KWebViewInterface getBoxViewInstance(Activity act);
    public abstract Intent getKWebviewActivity(Context context,int jumpType);

    public synchronized static Router_H5tbx getInstance(){
        if(sf==null || sf.get()==null){
            Object o = null;
            try {
                o = Class.forName(clazz).newInstance();
            }catch (Exception e) {
                e.printStackTrace();
            }
            if(o!=null){
                sf = new SoftReference<Router_H5tbx>((Router_H5tbx)o);
                return (Router_H5tbx)o;
            }
        }
        return sf == null ? null : sf.get();
    }
}
